<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      * {
        margin: 0;
        padding: 0;
        background-color: #333;
      }

      /* 相同类型的同级元素 */
      p:nth-of-type(2n + 1) {
        color: #fff;
      }
      p:nth-of-type(2n) {
        color: #13db;
      }

      /* 针对子元素 */
      .wrap:nth-child(2n + 1) {
        color: #f77;
      }
    </style>
  </head>
  <body>
    <div class="wrap">
      <p>这是p标签1 fff</p>
      <p>这是p标签2 13db</p>
      <h1>这是h1标签</h1>
      <p>这是p标签3 fff</p>
      <h2>这是h2标签</h2>
      <p>这是p标签4 13db</p>
    </div>
  </body>
</html>
